package com.travelplanning.admin.controller;

import com.travelplanning.admin.common.convention.Result;
import com.travelplanning.admin.common.convention.Results;
import com.travelplanning.admin.dao.mapper.ContentMapeper;
import com.travelplanning.admin.dto.req.CommentAddReqDTO;
import com.travelplanning.admin.dto.resp.CommentQueryResqDTO;
import com.travelplanning.admin.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@Tag(name = "评论相关接口")
public class CommentController {
    private final CommentService commentService;


    /**
     *用户新增评论
     */
    @Operation(summary = "新增评论")
    @PostMapping("/api/travel-planning/v1/comment/save")
    public Result<Void> commentSave(@RequestBody  CommentAddReqDTO requestParam){
        return Results.success(commentService.addComment(requestParam));
    }

    /**
     * 根据文章id查找评论
     */
    @Operation(summary = "根据文章ID查评论")
    @GetMapping("/api/travel-planning/v1/comment/query/{contentid}")
    public Result<List<CommentQueryResqDTO>> queryComment(@PathVariable("contentid") String requestParam){
       return Results.success(commentService.queryAllComments(requestParam));
    }
}
